<template>
    <el-input v-model="form.username" placeholder="Please input" />
    <el-input v-model="form.password"></el-input>
    <el-input v-model="form.code"></el-input>
    <el-image :src="codeImage"></el-image>
    <el-button @click="submitFn">登陆</el-button>
</template>
<script setup lang="ts">
import {ref} from 'vue'
import { getCode,login } from '@/api/common'
import { useTokenStore } from '@/store/token'
import { encrypt } from '@/utils/rsaEncrypt.js'
import router from '@/routes'
const tokenStore = useTokenStore()
const form = ref({
    username:'admin',
    password:'123456',
    uuid:'',
    code:''
})
const codeImage = ref('')
const getCodeImage = async() =>{
    let res = await getCode()
    // if(res.status == 10){
        codeImage.value = res.data.img
        form.value.uuid = res.data.uuid
    // }
}
const submitFn = async() =>{
    // let res = await login({
    //     code:form.value.code,
    //     username:form.value.username,
    //     uuid:form.value.uuid,
    //     password: encrypt(form.value.password)
    // })
    // if(res.code == 200){
        // tokenStore.setToken(res.data.token)
        router.push({
            path:'/index'
        })
    // }
    // setTimeout(()=>{
    //     tokenStore.removeToken()
    // },20000)
    // console.log(res)
    
}
const init = () =>{
    // getCodeImage()
}
init()
</script>